package com.bauer.java.hadoop.mrduce;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.util.Random;

/**
 * @program: java
 * @description:
 * @author: bauer weo
 * @create: 2019-07-28 10:49
 */
public class GenWordCount {

    public static void main(String[] args) throws Exception {
        File file = new File(GenWordCount.class.getResource("/").getPath() + "word.txt");
        OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file));
        for (int j = 0; j < 1000000000; j++) {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < 10; i++) {
                sb.append(genRandomString());
                sb.append(' ');
            }
            writer.write(sb.toString() + "\n");
            writer.flush();
            System.out.println(j);
        }

        writer.close();
    }

    public static String genRandomString() {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 5; i++) {
            Random random = new Random();
            char a = (char) (random.nextInt(10) + 97);
            sb.append(a);
        }
        return sb.toString();
    }
}
